<!--

Copyright 2015 Valmet Automation Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

<script type="text/javascript">
    RED.nodes.registerType('OpcUa-Item',{
        category: 'opcua',
        color:"#3FADB5",
        defaults: {
            item: {value: "", required: true},
            datatype: {value: "", required: true},
            value: {value: null},
            name: {value: ""}
        },
        inputs:1,
        outputs:1,
        align: "right",
        icon: "opcuanodeLogo.png",
        label: function() {
            return this.name || "OPC UA Item";
        },
        labelStyle: function() {
            return this.name?"node_label_italic":"";
        }
    });
</script>



<script type="text/x-red" data-template-name="OpcUa-Item">
    <div class="form-row">
        <label for="node-input-item"><i class="icon-tasks"></i> Item</label>
        <input type="text" id="node-input-item" placeholder="ns=2;s=MySwitch or ns=2;i=1234 or br=/objects/3:Simulation/3:Counter">
    </div>
    <div class="form-row">
        <label for="node-input-datatype"><i class="icon-tasks"></i> Type</label>
        <select type="text" id="node-input-datatype">
            <option value="Int8">Int8</option>
            <option value="Int16">Int16</option>
            <option value="Int32">Int32</option>
            <option value="Int64">Int64</option>
            <option value="UInt8">UInt8</option>
            <option value="UInt16">UInt16</option>
            <option value="UInt32">UInt32</option>
            <option value="UInt64">UInt64</option>
            <option value="Byte">Byte</option>
            <option value="SByte">SByte</option>
            <option value="Float">Float</option>
            <option value="Double">Double</option>
            <option value="Boolean">Boolean</option>
            <option value="String">String</option>
            <option value="LocalizedText">LocalizedText</option>
			<option value="DateTime">DateTime</option>
            <option value="Int8 Array">Int8 Array</option>
            <option value="Int16 Array">Int16 Array</option>
            <option value="Int32 Array">Int32 Array</option>
            <option value="UInt8 Array">UInt8 Array</option>
            <option value="UInt16 Array">UInt16 Array</option>
            <option value="UInt32 Array">UInt32 Array</option>
            <option value="Byte Array">Byte Array</option>
            <option value="SByte Array">SByte Array</option>
            <option value="String Array">String Array</option>
            <option value="Float Array">Float Array</option>
            <option value="Double Array">Double Array</option>
            <option value="Boolean Array">Boolean Array</option>
            <option value="Extension Object">ExtensionObject</option>
            <option value="Extension Object Array">ExtensionObject Array</option>
        </select>
    </div>
    <div class="form-row">
        <label for="node-input-value"><i class="icon-tag"></i> Value</label>
        <input type="text" id="node-input-value" placeholder="">
    </div>
    <div class="form-row">
        <label for="node-input-name"><i class="icon-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="">
    </div>
</script>



<script type="text/x-red" data-help-name="OpcUa-Item">
    <p>Defines OPC UA item, type and value.</p>
    <p>Item contains valid OPC UA address like ns=2;i=4 OR ns=3;s=MyVariable</p>
    <p>There are not all Types possible for now, but you can select some.</p>
    <p>Value is needed only if item will be written to OPC UA server.</p>
    <p>If value isn't filled, OpcUa-Item sends input <strong>msg.payload</strong>.</p>
    <p>Array values are delimited by , and must be given in following syntax:</p>
    <p>5,4,3,2,1</p>
    <p><strong>NOTE:</strong> Item value can be used as initial value when msg.payload is empty.</p>
    <p>      Otherwise msg.payload is used to set value.</p>
</script>